﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Input;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO.IsolatedStorage;
using System.Linq;
using DDU.DataModel;

namespace DDU.ViewModel
{
    public class FictionsViewModel : ViewModelBase
    {
        public ObservableCollection<FictionInfo> ItemsOfFictions
        {
            get
            {
                if (IsDesignMode)
                {
                    return null;
                }
                else
                {
                    using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication())
                    {
                        IEnumerable<FictionInfo> items = store.GetFileNames(ConstKeys.FictionsDirectoryName + "\\*.ddu").Select(s => new FictionInfo(ConstKeys.FictionsDirectoryName + "\\" + s));
                        return new ObservableCollection<FictionInfo>(items);
                    }
                }
            }
        }
    }
}
